<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <title>上实环境水务</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <style>
    body {
      margin: 0;
      padding: 0;
      font-family: Arial, sans-serif;
    }

    .container {
      width: 100%;
      height: 100vh;
    }

    iframe {
      width: 100%;
      height: 100%;
      border: none;
      display: block;
    }
  </style>
</head>
<body>

<div class="container">
  <iframe
          src="https://admin.sovitjs.com/publish_3d/3848008930978430976"
          title="3D 场景"
          allowfullscreen>
  </iframe>
</div>

<script>
  (function() {
    'use strict';

    // 配置参数
    const config = {
      TARGET_BASE64: "iVBORw0KGgoAAAANSUhEUgAAAZAAAAEECAYAAAAGSGKZAAAAAXNSR",
      LOG_STYLE: "color: #f44336; font-weight: bold;",
      SCAN_DELAY: 1000, // 初始扫描延迟(ms)
      SCAN_INTERVAL: 5000 // 定期扫描间隔(ms)
    };

    // 核心扫描函数
    function scanForBase64PNG() {
      const startTime = performance.now();
      let removalCount = 0;

      // 高效选择器：只扫描可能包含背景图片的元素
      const elements = document.querySelectorAll(
              'div, span, a, li, td, th, section, article, header, footer'
      );

      elements.forEach(el => {
        try {
          // 检查计算样式
          const bgImage = getComputedStyle(el).backgroundImage;
          if (bgImage.includes('data:image/png') &&
                  bgImage.includes(config.TARGET_BASE64)) {
            el.style.backgroundImage = 'none';
            removalCount++;
            console.log(`%c[扫描器] 已移除元素背景:`, config.LOG_STYLE, el);
          }
        } catch (e) {
          // 忽略跨域样式访问错误
        }
      });

      // 性能监控
      if (removalCount > 0) {
        const duration = (performance.now() - startTime).toFixed(2);
        console.log(
                `%c[扫描器] 扫描完成! 已移除 ${removalCount} 个元素 (耗时 ${duration}ms)`,
                config.LOG_STYLE
        );
      }
    }

    // 初始化函数
    function initScanner() {
      console.log('%c[扫描器] 初始化扫描器...', config.LOG_STYLE);

      // 初始扫描
      setTimeout(scanForBase64PNG, config.SCAN_DELAY);

      // 定期扫描
      setInterval(scanForBase64PNG, config.SCAN_INTERVAL);

      // 监听DOM变化
      const observer = new MutationObserver(function(mutations) {
        let found = false;

        for (const mutation of mutations) {
          for (const node of mutation.addedNodes) {
            if (node.nodeType !== 1) continue;

            // 快速检查新增节点
            if (node.style &&
                    node.style.backgroundImage.includes('data:image/png') &&
                    node.style.backgroundImage.includes(config.TARGET_BASE64)) {
              node.style.backgroundImage = 'none';
              found = true;
            }
          }
        }

        if (found) {
          console.log('%c[扫描器] 检测到动态内容变化，触发扫描', config.LOG_STYLE);
          scanForBase64PNG();
        }
      });

      observer.observe(document, {
        childList: true,
        subtree: true,
        attributes: false,
        characterData: false
      });

      // 在卸载时清理
      window.addEventListener('unload', () => {
        observer.disconnect();
      });
    }

    // 根据页面加载状态启动扫描器
    if (document.readyState === 'loading') {
      document.addEventListener('DOMContentLoaded', initScanner);
    } else {
      initScanner();
    }
  })();
</script>

</body>
</html>